

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>ukfm.geometry.sek3 &mdash; Unscented Kalman Filtering on (Parallelizable) Manifolds alpha documentation</title>
  

  
  

  

  
  
    

  

  
  
    <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" />
  

  
    <link rel="stylesheet" href="../../../_static/gallery.css" type="text/css" />
  
    <link rel="stylesheet" href="../../../_static/custom.css" type="text/css" />
  

  
        <link rel="index" title="Index"
              href="../../../genindex.html"/>
        <link rel="search" title="Search" href="../../../search.html"/>
    <link rel="top" title="Unscented Kalman Filtering on (Parallelizable) Manifolds alpha documentation" href="../../../index.html"/>
        <link rel="up" title="Module code" href="../../index.html"/> 

  
  <script src="../../../_static/js/modernizr.min.js"></script>

</head>

<body class="wy-body-for-nav" role="document">

  <div class="wy-grid-for-nav">

    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search">
          

          
            <a href="../../../index.html" class="icon icon-home"> Unscented Kalman Filtering on (Parallelizable) Manifolds
          

          
            
            <img src="../../../_static/blacklogo.png" class="logo" />
          
          </a>

          
            
            
              <div class="version">
                1.0
              </div>
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
                <ul>
<li class="toctree-l1"><a class="reference internal" href="../../../install.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../auto_examples/localization.html">Tutorial</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../examples.html">Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../benchmarks.html">Benchmarks</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../filter.html">Filters</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../model.html">Models</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../geometry.html">Lie Groups</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../matlab.html">Matlab</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../license.html">License</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../bibliography.html">Bibliography</a></li>
</ul>

            
          
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" role="navigation" aria-label="top navigation">
        <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
        <a href="../../../index.html">Unscented Kalman Filtering on (Parallelizable) Manifolds</a>
      </nav>


      
      <div class="wy-nav-content">
        <div class="rst-content">
          





<div role="navigation" aria-label="breadcrumbs navigation">
  <ul class="wy-breadcrumbs">
    <li><a href="../../../index.html">Docs</a> &raquo;</li>
      
          <li><a href="../../index.html">Module code</a> &raquo;</li>
      
    <li>ukfm.geometry.sek3</li>
      <li class="wy-breadcrumbs-aside">
        
          
        
      </li>
  </ul>
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <h1>Source code for ukfm.geometry.sek3</h1><div class="highlight"><pre>
<span></span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
<span class="kn">from</span> <span class="nn">ukfm.geometry.so3</span> <span class="k">import</span> <span class="n">SO3</span>


<div class="viewcode-block" id="SEK3"><a class="viewcode-back" href="../../../geometry.html#ukfm.SEK3">[docs]</a><span class="k">class</span> <span class="nc">SEK3</span><span class="p">:</span>
    <span class="sd">&quot;&quot;&quot;Homogeneous transformation matrix in :math:`SE_k(3)`.</span>

<span class="sd">    .. math::</span>

<span class="sd">        SE_k(3) &amp;= \\left\\{ \\mathbf{T}=</span>
<span class="sd">                \\begin{bmatrix}</span>
<span class="sd">                    \\mathbf{C} &amp; \\mathbf{r_1} &amp; \\cdots &amp;\\mathbf{r}_k \\\\</span>
<span class="sd">                    \\mathbf{0}^T &amp; &amp; \\mathbf{I} &amp;</span>
<span class="sd">                \\end{bmatrix} \\in \\mathbb{R}^{(3+k) \\times (3+k)} </span>
<span class="sd">                ~\\middle|~ \\mathbf{C} \\in SO(3), \\mathbf{r}_1 </span>
<span class="sd">                \\in \\mathbb{R}^3, \cdots, \\mathbf{r}_k \\in </span>
<span class="sd">                \\mathbb{R}^3 \\right\\} \\\\</span>
<span class="sd">        \\mathfrak{se}_k(3) &amp;= \\left\\{ \\boldsymbol{\\Xi} =</span>
<span class="sd">        \\boldsymbol{\\xi}^\\wedge \\in \\mathbb{R}^{(3+k) </span>
<span class="sd">        \\times (3+k)} ~\\middle|~</span>
<span class="sd">         \\boldsymbol{\\xi}=</span>
<span class="sd">            \\begin{bmatrix}</span>
<span class="sd">                \\boldsymbol{\\phi} \\\\ \\boldsymbol{\\rho}_1  \\\\ </span>
<span class="sd">                \\vdots  \\\\ \\boldsymbol{\\rho}_k</span>
<span class="sd">            \\end{bmatrix} \\in \\mathbb{R}^{3+3k}, \\boldsymbol{\\phi} </span>
<span class="sd">            \in \\mathbb{R}^3, \\boldsymbol{\\rho}_1 \\in \\mathbb{R}^3, </span>
<span class="sd">            \\cdots, \\boldsymbol{\\rho}_k \\in \\mathbb{R}^3 \\right\\}</span>

<span class="sd">    &quot;&quot;&quot;</span>
<div class="viewcode-block" id="SEK3.exp"><a class="viewcode-back" href="../../../geometry.html#ukfm.SEK3.exp">[docs]</a>    <span class="nd">@classmethod</span>
    <span class="k">def</span> <span class="nf">exp</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">xi</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Exponential map for :math:`SE_k(3)`, which computes a transformation </span>
<span class="sd">        from a tangent vector:</span>

<span class="sd">        .. math::</span>

<span class="sd">            \\mathbf{T}(\\boldsymbol{\\xi}) =</span>
<span class="sd">            \\exp(\\boldsymbol{\\xi}^\\wedge) =</span>
<span class="sd">            \\begin{bmatrix}</span>
<span class="sd">                \\exp(\\boldsymbol{\\phi}^\\wedge) &amp; \\mathbf{J} </span>
<span class="sd">                \\boldsymbol{\\rho}_1 &amp; \\cdots  &amp; \\mathbf{J} </span>
<span class="sd">                \\boldsymbol{\\rho}_k  \\\\</span>
<span class="sd">                \\mathbf{0} ^ T &amp; &amp; \\mathbf{I} &amp;</span>
<span class="sd">            \\end{bmatrix}</span>

<span class="sd">        This is the inverse operation to :meth:`~ukfm.SEK3.log`.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">k</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">xi</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">/</span><span class="mi">3</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span>
        <span class="n">Xi</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">reshape</span><span class="p">(</span><span class="n">xi</span><span class="p">[</span><span class="mi">3</span><span class="p">:],</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="n">k</span><span class="p">),</span> <span class="s1">&#39;F&#39;</span><span class="p">)</span>
        <span class="n">chi</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">eye</span><span class="p">(</span><span class="mi">3</span><span class="o">+</span><span class="n">k</span><span class="p">)</span>
        <span class="n">chi</span><span class="p">[:</span><span class="mi">3</span><span class="p">,</span> <span class="p">:</span><span class="mi">3</span><span class="p">]</span> <span class="o">=</span> <span class="n">SO3</span><span class="o">.</span><span class="n">exp</span><span class="p">(</span><span class="n">xi</span><span class="p">[:</span><span class="mi">3</span><span class="p">])</span>
        <span class="n">chi</span><span class="p">[:</span><span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">:]</span> <span class="o">=</span> <span class="n">SO3</span><span class="o">.</span><span class="n">left_jacobian</span><span class="p">(</span><span class="n">xi</span><span class="p">[:</span><span class="mi">3</span><span class="p">])</span><span class="o">.</span><span class="n">dot</span><span class="p">(</span><span class="n">Xi</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">chi</span></div>

<div class="viewcode-block" id="SEK3.inv"><a class="viewcode-back" href="../../../geometry.html#ukfm.SEK3.inv">[docs]</a>    <span class="nd">@classmethod</span>
    <span class="k">def</span> <span class="nf">inv</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">chi</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Inverse map for :math:`SE_k(3)`.</span>

<span class="sd">        .. math::</span>

<span class="sd">            \\mathbf{T}^{-1} =</span>
<span class="sd">            \\begin{bmatrix}</span>
<span class="sd">                \\mathbf{C}^T  &amp; -\\mathbf{C}^T \\boldsymbol{\\rho}_1  &amp;</span>
<span class="sd">                    \\cdots &amp; &amp; -\\mathbf{C}^T \\boldsymbol{\\rho}_k \\\\</span>
<span class="sd">                \\mathbf{0} ^ T &amp; &amp; \\mathbf{I} &amp;</span>
<span class="sd">            \\end{bmatrix}</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">k</span> <span class="o">=</span> <span class="n">chi</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">-</span> <span class="mi">3</span>
        <span class="n">chi_inv</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">eye</span><span class="p">(</span><span class="mi">3</span><span class="o">+</span><span class="n">k</span><span class="p">)</span>
        <span class="n">chi_inv</span><span class="p">[:</span><span class="mi">3</span><span class="p">,</span> <span class="p">:</span><span class="mi">3</span><span class="p">]</span> <span class="o">=</span> <span class="n">chi</span><span class="p">[:</span><span class="mi">3</span><span class="p">,</span> <span class="p">:</span><span class="mi">3</span><span class="p">]</span><span class="o">.</span><span class="n">T</span>
        <span class="n">chi_inv</span><span class="p">[:</span><span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">:]</span> <span class="o">=</span> <span class="o">-</span><span class="n">chi_inv</span><span class="p">[:</span><span class="mi">3</span><span class="p">,</span> <span class="p">:</span><span class="mi">3</span><span class="p">]</span><span class="o">.</span><span class="n">dot</span><span class="p">(</span><span class="n">chi</span><span class="p">[:</span><span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">:])</span>
        <span class="k">return</span> <span class="n">chi_inv</span></div>

<div class="viewcode-block" id="SEK3.log"><a class="viewcode-back" href="../../../geometry.html#ukfm.SEK3.log">[docs]</a>    <span class="nd">@classmethod</span>
    <span class="k">def</span> <span class="nf">log</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">chi</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Logarithmic map for :math:`SE_k(3)`, which computes a tangent vector </span>
<span class="sd">        from a transformation:</span>

<span class="sd">        .. math::</span>
<span class="sd">        </span>
<span class="sd">            \\boldsymbol{\\xi}(\\mathbf{T}) =</span>
<span class="sd">            \\ln(\\mathbf{T})^\\vee =</span>
<span class="sd">            \\begin{bmatrix}</span>
<span class="sd">                \\ln(\\boldsymbol{C}) ^\\vee \\\\</span>
<span class="sd">                \\mathbf{J} ^ {-1} \\mathbf{r}_1 \\\\ \\vdots \\\\</span>
<span class="sd">                \\mathbf{J} ^ {-1} \\mathbf{r}_k</span>
<span class="sd">            \\end{bmatrix}</span>

<span class="sd">        This is the inverse operation to :meth:`~ukfm.SEK3.exp`.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">phi</span> <span class="o">=</span> <span class="n">SO3</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">chi</span><span class="p">[:</span><span class="mi">3</span><span class="p">,</span> <span class="p">:</span><span class="mi">3</span><span class="p">])</span>
        <span class="n">Xi</span> <span class="o">=</span> <span class="n">SO3</span><span class="o">.</span><span class="n">inv_left_jacobian</span><span class="p">(</span><span class="n">phi</span><span class="p">)</span><span class="o">.</span><span class="n">dot</span><span class="p">(</span><span class="n">chi</span><span class="p">[:</span><span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">:])</span>
        <span class="n">xi</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">hstack</span><span class="p">([</span><span class="n">phi</span><span class="p">,</span> <span class="n">Xi</span><span class="o">.</span><span class="n">flatten</span><span class="p">(</span><span class="s1">&#39;F&#39;</span><span class="p">)])</span>
        <span class="k">return</span> <span class="n">xi</span></div></div>
</pre></div>

           </div>
          </div>
          <footer>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright 2019, Martin Brossard, Axel Barrau, Silvère Bonnabel.

    </p>
  </div>
  Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>

        </div>
      </div>

    </section>

  </div>
  


  

    <script type="text/javascript">
        var DOCUMENTATION_OPTIONS = {
            URL_ROOT:'../../../',
            VERSION:'alpha',
            COLLAPSE_INDEX:false,
            FILE_SUFFIX:'.html',
            HAS_SOURCE:  true
        };
    </script>
      <script type="text/javascript" src="../../../_static/jquery.js"></script>
      <script type="text/javascript" src="../../../_static/underscore.js"></script>
      <script type="text/javascript" src="../../../_static/doctools.js"></script>
      <script type="text/javascript" src="../../../_static/language_data.js"></script>
      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>

  

  
  
    <script type="text/javascript" src="../../../_static/js/theme.js"></script>
  

  
  
  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.StickyNav.enable();
      });
  </script>
   

</body>
</html>